Add LLDB debugger support to swift-test command#9085
Open
plemarquand wants to merge 39 commits intoswiftlang:mainfrom
Open
Add LLDB debugger support to swift-test command#9085plemarquand wants to merge 39 commits intoswiftlang:mainfrom
plemarquand wants to merge 39 commits intoswiftlang:mainfrom
Conversation
41c3aa6 to
5a8044c
Compare
pmattos
approved these changes
Sep 2, 2025
pmattos
reviewed
Sep 2, 2025
pmattos
reviewed
Sep 2, 2025
4d46294 to
1f6e90f
Compare
bkhouri
reviewed
Sep 9, 2025
89e4856 to
15ae86c
Compare
64fb75e to
280f4e1
Compare
280f4e1 to
0eaca53
Compare
0eaca53 to
3172e88
Compare
6430e6e to
8f41436
Compare
8f41436 to
d52eefb
Compare
Introduces interactive debugging capabilities to `swift test` via a `--debugger` flag enabling developers to failing tests directly within LLDB. This adds debugging parity with `swift run --debugger` which allows users to debug their executables directly. When launching lldb this implenentation uses `execv()` to replace the `swift-test` process with LLDB. This approach avoids process hierarchy complications and ensures LLDB has full terminal control for interactive debugging features. When there is only one type of tests the debugger creates a single LLDB target configured specifically for that framework. For XCTest, this means targeting the test bundle with xctest as the executable, while Swift Testing targets the test binary directly with appropriate command-line arguments. When both testing frameworks have tests available we create multiple LLDB targets within a single debugging session. A Python script automatically switches targets as the executable exits, which lets users debug both types of tests spread across two executables in the same session. The Python script also maintains breakpoint persistence across target switches, allowing you to set a breakpoint for either test type no matter the active target. Finally, we add a `failbreak` command alias that sets breakpoint(s) that break on test failure, allowing users to automatically stop on failed tests. Issue: swiftlang#8129
243997b to
dccd4fe
Compare
Contributor
Author
|
@swift-ci test |
Contributor
Author
|
@swift-ci test windows |
Contributor
Author
|
@swift-ci test windows platform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces interactive debugging capabilities to
swift testvia a--debuggerflag enabling developers to failing tests directly within LLDB.This adds debugging parity with
swift run --debuggerwhich allows users to debug their executables directly.When launching lldb this implenentation uses
execv()to replace theswift-testprocess with LLDB. This approach avoids process hierarchy complications and ensures LLDB has full terminal control for interactive debugging features.When there is only one type of test the debugger creates a single LLDB target configured specifically for that framework. For XCTest, this means targeting the test bundle with xctest as the executable, while Swift Testing targets the test binary directly with appropriate command-line arguments.
When both testing frameworks have tests available we create multiple LLDB targets within a single debugging session. A Python script automatically switches targets as the executable exits, which lets users debug both types of tests spread across two executables in the same session. The Python script also maintains breakpoint persistence across target switches, allowing you to set a breakpoint for either test type no matter the active target.
Note that the CI smoke tests use an old version of LLDB that ships Swift 5.9.2. The
--debuggerfeature relies on the version of LLDB that ships alongside swift-package-manager in the latest toolchain, and so many supporting tests are skipped when running in the smoke test jobs in CI.Issue: #8129